import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from "@/views/layout/index.vue";

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        component: Layout,
        redirect: '/welcome',
        children: [
            {
                path: 'statistic',
                name: '统计',
                component: () => import('@/views/welcome/statistic.vue')
            },
            {
                path: 'welcome',
                name: '欢迎页',
                component: () => import('@/views/welcome/index.vue')
            },
            {
                path: 'user',
                name: '用户管理',
                component: () => import('@/views/user/index.vue'),
                meta: { level: '1' }
            },
            {
                path: 'invoice_sf',
                name: '发票管理(顺丰)',
                component: () => import('@/views/invoice/index.vue'),
                meta: { level: '1' }
            },
            {
                path: 'invoice_sf/add',
                name: '添加发票(顺丰)',
                component: () => import('@/views/invoice/add.vue')
            },
            {
                path: 'invoice_sf/detail',
                name: '发票详情(顺丰)',
                component: () => import('@/views/invoice/detail.vue')
            },
            {
                path: 'invoice_hf',
                name: '发票管理(合丰)',
                component: () => import('@/views/invoice/index.vue'),
                meta: { level: '1' }
            },
            {
                path: 'invoice_hf/add',
                name: '添加发票(合丰)',
                component: () => import('@/views/invoice/add.vue')
            },
            {
                path: 'invoice_hf/detail',
                name: '发票详情(合丰)',
                component: () => import('@/views/invoice/detail.vue')
            },
            {
                path: 'template',
                name: '模版中心',
                component: () => import('@/views/template/index.vue'),
                meta: { level: '1' }
            },
            {
                path: 'personalCenter',
                name: '个人中心',
                component: () => import('@/views/user/personalCenter.vue'),
                meta: { level: '1' }
            },
            {
                path: 'help',
                name: '教程',
                component: () => import('@/views/help/index.vue')
            },
            {
                path: 'logs',
                name: '日志',
                component: () => import('@/views/hidden/logs.vue')
            }
        ]
    },
    {
        path: '/login',
        name: '登录页',
        component: () => import('@/views/login/index.vue')
    }
    // {
    //     path: '/:pathMatch(.*)*',
    //     redirect: '/404'
    // }
]

const router = createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    // history: createWebHashHistory(),
    history: createWebHashHistory(),
    routes
})

export default router
